package com.guli.gulimall.test.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author WZH
 * @title: MyThreadPool
 * @projectName gulimall-java
 * @description:
 * @date 2022/2/8
 */
@Configuration
public class MyThreadPool {
    @Bean
    public ThreadPoolExecutor getThreadPoolExecutor(MyThreadPoolProperties properties){
        return new ThreadPoolExecutor(properties.getCoreSize(),
                properties.getMaxSize(),
                properties.getKeepAliveTime(),
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(100000),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
    }
}
